﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Text;
using System.Web.Mvc.Ajax;

namespace MvcApplication2.Helpers
{
    public static class Payding
    {
        public static MvcHtmlString PadingNavigator(this HtmlHelper helper, int pageNum, int itemsCount, int PageSize)
        {
            StringBuilder sb = new StringBuilder();
            if (pageNum > 0)
            {
                sb.Append(helper.ActionLink("<", "Index", new { pageNum = pageNum - 1 }));

                
            }
            else
            {
                sb.Append(HttpUtility.HtmlEncode("<"));

            }
            sb.Append(" ");
            int pagesCount = (int)Math.Ceiling((double)itemsCount / PageSize);
            if (pageNum < pagesCount - 1)
            {
                sb.Append(helper.ActionLink(">", "Index", new { pageNum = pageNum + 1 }));
                
            }
            else
            {
                sb.Append(HttpUtility.HtmlEncode(">"));

            }

            return MvcHtmlString.Create(sb.ToString());
        }


        public static MvcHtmlString PadingNavigator2(this HtmlHelper helper, int pageNum, int itemsCount, int PageSize)
        {
            StringBuilder sb = new StringBuilder();
            if (pageNum > 0)
            {
                sb.Append(helper.ActionLink("<", "FacultyDetails", new { pageNum = pageNum - 1 }));


            }
            else
            {
                sb.Append(HttpUtility.HtmlEncode("<"));

            }
            sb.Append(" ");
            int pagesCount = (int)Math.Ceiling((double)itemsCount / PageSize);
            if (pageNum < pagesCount - 1)
            {
                sb.Append(helper.ActionLink(">", "FacultyDetails", new { pageNum = pageNum + 1 }));

            }
            else
            {
                sb.Append(HttpUtility.HtmlEncode(">"));

            }

            return MvcHtmlString.Create(sb.ToString());
        }

        public static MvcHtmlString PadingNavigator3(this HtmlHelper helper, int pageNum, int itemsCount, int PageSize)
        {
            StringBuilder sb = new StringBuilder();
            if (pageNum > 0)
            {
                sb.Append(helper.ActionLink("<", "SpecialityDetails", new { pageNum = pageNum - 1 }));


            }
            else
            {
                sb.Append(HttpUtility.HtmlEncode("<"));

            }
            sb.Append(" ");
            int pagesCount = (int)Math.Ceiling((double)itemsCount / PageSize);
            if (pageNum < pagesCount - 1)
            {
                sb.Append(helper.ActionLink(">", "SpecialityDetails", new { pageNum = pageNum + 1 }));

            }
            else
            {
                sb.Append(HttpUtility.HtmlEncode(">"));

            }

            return MvcHtmlString.Create(sb.ToString());
        }

        public static MvcHtmlString PadingNavigator4(this HtmlHelper helper, int pageNum, int itemsCount, int PageSize)
        {
            StringBuilder sb = new StringBuilder();
            if (pageNum > 0)
            {
                sb.Append(helper.ActionLink("<", "ScoreDetails", new { pageNum = pageNum - 1 }));


            }
            else
            {
                sb.Append(HttpUtility.HtmlEncode("<"));

            }
            sb.Append(" ");
            int pagesCount = (int)Math.Ceiling((double)itemsCount / PageSize);
            if (pageNum < pagesCount - 1)
            {
                sb.Append(helper.ActionLink(">", "ScoreDetails", new { pageNum = pageNum + 1 }));

            }
            else
            {
                sb.Append(HttpUtility.HtmlEncode(">"));

            }

            return MvcHtmlString.Create(sb.ToString());
        } 
        }
    }
